[Testing] Restore exact EVM updated-register count assertion - #8629
Conversation
📝 WalkthroughWalkthroughThe COA transaction tests now verify exact register update counts. The new helper uses SHA-256-derived UUID partition selection to allow one fewer update when the partition is zero. ChangesCOA register count validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
fvm/evm/evm_test.go (1)
7192-7204: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd
t.Helper()to the assertion helper.
assertUpdatedRegisterCounttakes*testing.Tand performs the assertion internally viaassert.Len. Withoutt.Helper(), a failure reports the line inside the helper (Line 7203) instead of the call site, which makes it harder to find which sub-test failed.♻️ Proposed fix
func assertUpdatedRegisterCount( t *testing.T, ctx fvm.Context, state *snapshot.ExecutionSnapshot, countNonZeroPartition int, ) { + t.Helper() expected := countNonZeroPartition blockID := ctx.BlockHeader.ID() if sha256.Sum256(blockID[:])[0] == 0 { expected-- } assert.Len(t, state.UpdatedRegisterIDs(), expected) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@fvm/evm/evm_test.go` around lines 7192 - 7204, Add t.Helper() at the start of assertUpdatedRegisterCount, before computing expected or calling assert.Len, so assertion failures report the caller’s location.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@fvm/evm/evm_test.go`:
- Around line 7192-7204: Add t.Helper() at the start of
assertUpdatedRegisterCount, before computing expected or calling assert.Len, so
assertion failures report the caller’s location.
Follow-up to #8626, which relaxed
assert.Len(state.UpdatedRegisterIDs(), 13)toNotEmptyin the COAdryCalltests because the count varied between runs — losing theability to catch write-amplification regressions.
The variance is now fully characterized: the test env uses a random block ID, and
environment.uuidPartition(=sha256(blockID)[0]at txnIndex 0) selects the UUIDregister. Partition 0 (probability 1/256) reuses the legacy
uuidregister → 12 updatedregisters; all other partitions create a fresh
uuid_Nregister → 13. This 1-in-256 caseis what made the original exact assertion flaky.
This PR restores an exact assertion via a small helper that computes the expected count
(12 or 13) from the block ID, keeping the fixture's full randomness. Both branches
verified: 15 random-block runs and 3 runs with partition 0 forced, all with
-race.Test-only change; no production code touched.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests